package com.way.designpatterncodepratice.factory.simpleFactory;

import com.way.designpatterncodepratice.factory.base.CheesePizza;
import com.way.designpatterncodepratice.factory.base.FruitPizza;
import com.way.designpatterncodepratice.factory.base.Pizza;

/**
 * @author liangliwei 80551025
 * @description
 * @date 2020-06-22
 */
public class SimplePizzaFactory {


    Pizza cretePizza(String pizzaType){
        /**
         * Pizza pizza 不能放到外面成员变量
         * 因为 PizzaStore 的循环中会不停调用这个方法 放到外面的话 pizza值有可能不会改变
         */
        Pizza pizza = null;
        if("cheese".equals(pizzaType)){
            pizza = new CheesePizza();
        }else if("fruit".equals(pizzaType)){
            pizza = new FruitPizza();
        }
        return pizza;
    }
}
